#define _CRT_SECURE_NO_WARNINGS 1
#include<iostream>
using namespace std;
typedef long long ll;
char a[12][12];
int fx, fy, cx, cy;
int flagf = 1, flagc = 1;
int f=0;
ll cnt;
void F()
{
	if (flagf == 1)
	{
		if (fx - 1 < 0 || a[fx - 1][fy] == '*')
			flagf++;
		else
			fx--;
	}
	else if (flagf == 2)
	{
		if (fy + 1 > 9 || a[fx][fy + 1] == '*')
			flagf++;
		else
			fy++;
	}
	else if (flagf == 3)
	{
		if (fx + 1 > 9 || a[fx + 1][fy] == '*')
			flagf++;
		else
			fx++;
	}
	else
	{
		if (fy - 1 < 0 || a[fx][fy - 1] == '*')
			flagf = 1;
		else
			fy--;
	}
}
void C()
{
	if (flagc == 1)
	{
		if (cx - 1 < 0 || a[cx - 1][cy] == '*')
			flagc++;
		else
			cx--;
	}
	else if (flagc == 2)
	{
		if (cy + 1 > 9 || a[cx][cy + 1] == '*')
			flagc++;
		else
			cy++;
	}
	else if (flagc == 3)
	{
		if (cx + 1 > 9 || a[cx + 1][cy] == '*')
			flagc++;
		else
			cx++;
	}
	else
	{
		if (cy - 1 < 0 || a[cx][cy - 1] == '*')
			flagc = 1;
		else
			cy--;
	}
}
int main()
{
	
	for (int i = 0; i < 10; i++)
	{
		for (int j = 0; j < 10; j++)
		{
			cin >> a[i][j];
			if (a[i][j] == 'F')
			{
				fx = i;
				fy = j;
				a[i][j] = '.';
			}
			if (a[i][j] == 'C')
			{
				cx = i;
				cy = j;
				a[i][j] = '.';
			}
		}
	}
	while (fx != cx || fy != cy)
	{
		F();
		C();
		cnt++;
		if (cnt > 20000)
		{
			f = 1;
			break;
		}
	}
	if (f) cout << 0 << endl;
	else cout << cnt << endl;
	return 0;
}
